function deep(obj) {
    let objNew = {};   
    if(obj instanceof Array){
        objNew=[]
    }
    for (let key in obj) {
        if (typeof obj[key] == "object" ) {
            //object
            objNew[key] = deep(obj[key]);
        } else {
            objNew[key] = obj[key];
        }
    }    
    return objNew;
}

let obj = {
    name: "李四",
    age: 100,
    sayName: function () {
        console.log(this.name);
    },
    sex: undefined,
    child: {
        name: "小李四",
        age: 80
    },
    arr:[{name:"王五"},{name:"赵六"}]
}
let objDeep = deep(obj);
obj.arr[0].name = "张三"
console.log(objDeep.arr[0].name);
console.log(objDeep);